from django.urls import re_path
from rest_framework_jwt.views import obtain_jwt_token

from apps.meiduo_admin.views.admin_views import AdminUserView, AdminGroupView
from apps.meiduo_admin.views.channel_view import GoodsChannelView, GoodsChannelGroupView, GoodsCategorylView
from apps.meiduo_admin.views.home_views import *
from apps.meiduo_admin.views.image_views import ImageView, SKUImageView
from apps.meiduo_admin.views.order_views import OrderModelView
from apps.meiduo_admin.views.perm_views import PermView, PermContentTypeView, GroupView, GroupPermView
from apps.meiduo_admin.views.sku_views import SKUGoodsView, SKUCategoryView, SPUSimpleView, SPUSpecView
from apps.meiduo_admin.views.spec_views import SpecView
from apps.meiduo_admin.views.spu_views import SPUView, BrandSimpleView, SPUCateSimpleView, OptionView, OptSpecSimpleView
from apps.meiduo_admin.views.user_views import UserView

from .views.login_views import *



urlpatterns = [
    # re_path(r'^authorizations/$', LoginView.as_view()),
    re_path(r'^authorizations/$', obtain_jwt_token),
    re_path(r'^statistical/total_count/$', UserTotalCountView.as_view()),
    re_path(r'^statistical/day_increment/$', UserDayCountView.as_view()),
    re_path(r'^statistical/day_active/$', UserActiveCountView.as_view()),
    re_path(r'^statistical/day_orders/$', UserOrderCountView.as_view()),
    re_path(r'^statistical/month_increment/$', UserMonthCountView.as_view()),
    re_path(r'^statistical/goods_day_views/$', GoodsDayView.as_view()),
    re_path(r'^users/$', UserView.as_view()),
    re_path(r'^skus/$', SKUGoodsView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^skus/(?P<pk>\d+)/$', SKUGoodsView.as_view({'get':'retrieve', "put": "update", "delete": "destroy"})),
    re_path(r'^skus/categories/$', SKUCategoryView.as_view()),
    re_path(r'^goods/simple/$', SPUSimpleView.as_view()),
    re_path(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecView.as_view()),
    re_path(r'^goods/$', SPUView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^goods/(?P<pk>\d+)/$', SPUView.as_view({'get': 'retrieve','put': 'update','delete': 'destroy'})),
    re_path(r'^goods/brands/simple/$', BrandSimpleView.as_view()),
    re_path(r'^goods/channel/categories/$', SPUCateSimpleView.as_view()),
    # 新增SPU可选二级或三级份额里
    re_path(r'^goods/channel/categories/(?P<pk>\d+)/$', SPUCateSimpleView.as_view()),

    re_path(r'^goods/specs/$', SpecView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^goods/specs/(?P<pk>\d+)/$', SpecView.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),


    # 选项路由：
    re_path(r'^specs/options/$', OptionView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^specs/options/(?P<pk>\d+)/$', OptionView.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),
    re_path(r'^goods/specs/simple/$', OptSpecSimpleView.as_view()),


    # 频道接口：
    re_path(r'^goods/channels/$', GoodsChannelView.as_view({"get": "list", "post": "create"})),
    re_path(r'^goods/channels/(?P<pk>\d+)/$', GoodsChannelView.as_view({"get": "retrieve",'put': 'update', 'delete': 'destroy'})),

    # 频道组接口：
    re_path(r'^goods/channel_types/$', GoodsChannelGroupView.as_view({"get": "list", "post": "create"})),
    re_path(r'^goods/channel_types/(?P<pk>\d+)/$', GoodsChannelGroupView.as_view({"get": "retrieve", 'put': 'update', 'delete': 'destroy'})),

    #商品类别
    re_path(r'^goods/categories/$',  GoodsCategorylView.as_view({"get": "list", "post": "create"})),
    re_path(r'^goods/categories/(?P<pk>\d+)/$',
            GoodsCategorylView.as_view({"get": "retrieve", 'put': 'update', 'delete': 'destroy'})),


    # 图片路由：
    re_path(r'^skus/images/$', ImageView.as_view({"get": "list", "post": "create"})),

    # 新增图片可选的SKU
    re_path(r'^skus/simple/$', SKUImageView.as_view({"get": "list"})),


    # 订单路由
    re_path(r'^orders/$', OrderModelView.as_view({"get": "list"})),

    re_path(r'^orders/(?P<pk>\d+)/$', OrderModelView.as_view({'get': 'retrieve'})),

    re_path(r'^orders/(?P<pk>\d+)/status/$', OrderModelView.as_view({'patch':'partial_update'})),


    # 用户权限路由
    re_path(r'^permission/perms/$', PermView.as_view({'get': 'list'})),
    # 新增权限可以选择的类型
    re_path(r'^permission/content_types/$', PermContentTypeView.as_view()),

    re_path(r'^permission/groups/$', GroupView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^permission/groups/(?P<pk>\d+)/$', GroupView.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),
    # 新增分组可选权限
    re_path(r'^permission/simple/$', GroupPermView.as_view()),



# 管理员用户
    re_path(r'^permission/admins/$', AdminUserView.as_view({'get': 'list', 'post': 'create'})),
    re_path(r'^permission/admins/(?P<pk>\d+)/$', AdminUserView.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),
		# 新增管理员可选权限
    re_path(r'^permission/groups/simple/$', AdminGroupView.as_view()),
]